package com.wuyan.locationdog.adapter

import androidx.annotation.LayoutRes
import com.arcsoft.commonbase.bean.GroupBeanContent
import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseViewHolder
import com.wuyan.locationdog.R
import com.wuyan.locationdog.help.GroupHelp


class HomeGroupListAdapter(@LayoutRes layoutResId: Int, data: MutableList<GroupBeanContent>?) :
    BaseQuickAdapter<GroupBeanContent, BaseViewHolder>(layoutResId, data) {

    override fun convert(holder: BaseViewHolder, item: GroupBeanContent) {
        holder.setText(R.id.tv_family_name, item.groupName)

        var indexOfFirst = data.indexOfFirst { it.groupId == GroupHelp.selectGroupBeanContent?.groupId }
        if (indexOfFirst == -1) {
            indexOfFirst = 0
        }
        if ( holder.adapterPosition==indexOfFirst) {
            holder.setVisible(R.id.iv_select, true)
            holder.setTextColorRes(R.id.tv_family_name, com.arcsoft.commonbase.R.color.text_color_selected)
        } else {
            holder.setGone(R.id.iv_select, true)
            holder.setTextColorRes(R.id.tv_family_name, com.arcsoft.commonbase.R.color.color_3)
        }
    }

}

